<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-30 20:02:30
 * @LastEditTime: 2020-02-28 11:25:38
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>

    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../css/local.css" />
    <!-- <link rel="stylesheet" type="text/css" href="../css/elementui.css" /> -->
    <link rel="stylesheet" href="../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <script type="text/javascript" src="../script/elementui.js"></script>
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/jquery.signalR-2.4.1.min.js"></script>
    <script type="text/javascript" src="../script/signalr-mediate.js"></script>
    <script type="text/javascript" src='http://36.26.80.127:20000/signalr/hubs'></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <style type="text/css">
        .content {
            display: flex;
            flex-direction: column;
        }

        #safeTop .van-button__content .van-button__icon {
            color: #323233;
        }

        .head {
            width: 100%;
            height: 50px;
            display: flex;
            padding: 10px 20px;
        }

        .head .van-button {
            margin-right: 10px;
        }

        .content-main {
            flex: 1;
            display: flex;
            background-color: #fff;
        }

        .content-main>div {
            width: 50%;
            height: 100%;
            overflow-y: auto;
        }

        .content-L {
            border-right: 1px solid #e2e2e2;
        }

        .content-main>div>.content-title {
            width: 100%;
            color: #1989fa;
            padding-left: 16px;
            padding-top: 3px;
            font-weight: 700;
            font-size: 18px;
            display: flex;
        }

        .content-main>div>.content-title .div {
            margin: auto 10px 3px auto;
        }

        .content-title>.content-title_span {
            color: green !important;
            display: inline-block;
            padding-left: 10px;
        }

        .content-main>div>.content-title .van-button {
            margin: auto 10px 3px auto;
        }

        .van-col {
            padding: 10px 13px;
        }

        .content-R-inner>span {
            position: absolute;
            top: 6px;
            left: 6px;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            z-index: 2000;
            background-color: #1989fa;
            color: #fff;
            text-align: center;
            line-height: 20px;
        }

        .content-R-inner {
            /* width: 100%; */
            position: relative;
            padding: 10px 13px;
            box-sizing: border-box;
            border: 1px solid #EAEAF5;
        }

        .content-R-inner>.van-icon {
            position: absolute;
            top: 6px;
            right: 6px;
            z-index: 2000;
            color: red;
        }

        .content-R-inner .van-field .van-field__label {
            width: auto;
            padding: 0;
        }

        .content-R-inner .van-field .van-field__control {
            text-align: left;
        }

        .bottomBtn {
            height: 50px;
            width: 100%;
            padding: 10px 10px;
            display: flex;
            position: fixed;
            bottom: 2%;

        }

        .bottomBtn .van-button {
            flex: 1;
            margin: 0 10px;
        }

        .div_input {
            display: flex;
            padding: 2% 0;
            width: 80%;
            /* border: 1px solid #ccc; */
        }

        .div_input span {
            font-size: 14px;
            width: 25%;
            display: inline-block;
            padding: 0 0 0 4%;
            color: #696a6b;
        }

        .div_input input {
            border: none;
            width: 90%;
        }

        .GSStartdiv {
            flex: 1;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .GSStartdiv .van-button {
            width: 15%;
        }

        .nav-barRight {
            width: 25%;
            position: absolute;
            top: 0;
            bottom: 0;
            right: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        /* .nav-barRight .van-button {
               padding: 2%;
           } */

        .van-radio_group {
            width: 82%;
            /* display: flex; */
            /* background-color: red; */
        }

        .van-radio_group .van-radio-group {
            display: flex;
            justify-content: space-between;
        }

        .van-tag {
            display: inline-block;
            width: 80%;
            /* background-color: red; */
        }

        .Operator {
            width: 80%;
            /* background-color: red; */
        }

        .van-tag {
            color: #0283ef;
            background: rgba(2, 131, 239, 0.1);
            margin-right: 3px;
            padding: 2px;
        }

        .selected {
            background-color: yellow;
        }

        .sheetdiv {
            height: 100%;
            width: 100%;
            overflow-y: scroll;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        .sheetdivchild {
            width: 13%;
            display: inline-block;
            flex-wrap: wrap;
            padding: 1% 0;
            box-sizing: border-box;
        }

        .sheetchild1 {
            font-weight: 600;
            background-color: #00FFFF;
            font-size: 16px;
        }

        .sheetchild2 {
            font-weight: 600;
            background-color: #00FF7F;
            font-size: 16px;
        }

        .SJNoActionsMF {
            font-size: 13px;
        }

        .sheetdivchild2 {
            height: 100%;
            width: 100%;
            overflow-y: scroll
        }

        .van-tags {
            color: #0283ef;
            background: rgba(2, 131, 239, 0.1);
            margin-right: 3px;
            padding: 2px;
        }

        .changeAllButton {
            background-color: #DDA0DD;
            border: none;
        }

        .tbuButton {
            border: none;
        }

        .addNewButton {
            background-color: green;
            border: none;
        }

        .content-RDiv {
            display: flex;
        }

        .content-RDiv .van-field {
            width: 50%;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box">
            <div class="van-nav-bar" id="safeTop">
                <div class="van-nav-bar__content">
                    <div class="van-nav-bar__left" @click="onClickLeft">
                        <i class="van-icon van-icon-arrow-left van-nav-bar__arrow"></i>
                    </div>
                    <div class="van-nav-bar__title van-ellipsis">
                        {{name + '列表'}}
                        <span :style='{color: connectStatus==true?"green":"yellow"}'> ( {{ connectStatus?'连接':'断开' }}
                            )</span>
                    </div>
                    <div class="nav-barRight">
                        <van-button class='changeAllButton' type="danger" icon="success" @click="changeAll"
                            size="small"> 切换 </van-button>
                        <van-button class='tbuButton' type="warning" icon="replay" @click="tbu" size="small">同步
                        </van-button>
                        <van-button class='addNewButton' type="info" icon="plus" size="small" @click="addNew">上架
                        </van-button>
                    </div>
                </div>
            </div>
            <div class="content">
                <div class="content-main">
                    <div class="content-L">
                        <div class="content-title">灌酸 <span class="content-title_span"
                                v-if='formData.IFSY'>（{{formData.IFSY}}）</span></div>
                        <van-field v-model="formData.PlanDate" readonly label="计划日期" placeholder="请选择计划日期"></van-field>
                        <van-field v-model="formData.ProductName" readonly label="产品名称" placeholder="请选择产品名称">
                        </van-field>
                        <van-field v-model="formData.BatchList.join(',')" readonly label="生产批次" placeholder="请选择生产批次">
                        </van-field>
                        <van-field v-model="formData.Date" readonly label="装配日期" placeholder="请选择装配日期"></van-field>
                        <van-field v-model="formData.KQty" readonly label="可装配数量" placeholder="请选择装配数量"></van-field>
                        <van-field v-model="formData.PlanQty" readonly label="计划数量" placeholder="请选择计划数量"></van-field>
                        <van-field v-model="formData.FinishedQty" readonly label="已上架数量" placeholder="请选择已上架数量">
                        </van-field>

                    </div>

                    <br>
                    <!-- PDA只有开始灌酸       没有上架 没有结束灌酸和提交按钮 -->
                    <!-- 平板上架没有开始灌酸 -->
                    <div class="content-R">
                        <div class="content-title">上架
                        </div>

                        <div class="content-RDiv">
                            <van-field v-model="formData.AcidEmpl" readonly label="灌酸工" placeholder="请选择灌酸工">
                            </van-field>
                            <van-field v-model="formData.GSQty" @blur="sendmsg(0)" label="灌酸数量" placeholder="请选择灌酸数量">
                            </van-field>
                        </div>

                        <van-row>
                            <van-col span="24" v-for="(item, index) in formData.shangjiaList">
                                <div class="content-R-inner">
                                    <span>{{index + 1}}</span>
                                    <van-icon name="delete" @click="deleteShangJiaList(index)"></van-icon>
                                    <div class="van-cell van-field">
                                        <div class="van-cell__title van-field__label">
                                            <span>模式</span>
                                        </div>
                                        <div class="van-radio_group">
                                            <van-radio-group v-model="item.MF" @input="changeMF(item.MF,index)">
                                                <van-radio name="A">A</van-radio>
                                                <van-radio name="B">B</van-radio>
                                                <van-radio name="C">C</van-radio>
                                                <van-radio name="D">D</van-radio>
                                                <van-radio name="E">E</van-radio>
                                            </van-radio-group>
                                        </div>
                                    </div>
                                    <div class="van-cell van-field" v-if='item.MF=="D"'>
                                        <div class="van-cell__title van-field__label">
                                            <span>上架号</span>
                                        </div>
                                        <div class="Operator" @click="handlerSJNo(index)">
                                            <span @click='closeTag($event,index,idx)' style="width: 24%;"
                                                class="van-tag van-tag--info" v-for="(ite, idx) in item.SJNo">
                                                {{ ite }}
                                                <i class="van-icon van-icon-clear"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <van-field v-model="item.SJNo" v-else label="上架号" placeholder="上架号" is-link readonly
                                        @click="handlerSJNo(index)" @blur="sendmsg(0)">

                                    </van-field>

                                    <div class="div_input">
                                        <!-- <van-field v-if='!item.SJQty' label="上架数量" v-model="item.SJQty" v-else readonly
                                               @click="handlerSJQty(index)" @blur="sendmsg(0)">
                                           </van-field> -->
                                        <span>上架数量</span>
                                        <input v-if='!item.SJQty&&item.MF!="D"' :value="item.SJQty" @blur="sendmsg(0)"
                                            @click="handlerSJQty(index)" readonly></input>

                                        <input v-else :value="item.SJQty"
                                            @change="changeblur($event.target.value,index)"></input>
                                        <!-- <input v-else v-model="item.SJQty"  @onblur='changeblur(item.SJQty,index)'></input> -->
                                    </div>
                                    <div class="GSStartdiv">
                                        <van-field v-model="item.GSStartDate" readonly label="开始灌酸时间"
                                            placeholder="请选择开始灌酸时间">
                                        </van-field>
                                        <van-button disabled v-if='item.GSStartDate' type="primary" size="mini">开始灌酸
                                        </van-button>
                                        <van-button v-else type="primary" size="mini" @click="handlerAdd('开始灌酸',index)">
                                            开始灌酸
                                        </van-button>
                                    </div>
                                    <div class="GSStartdiv">
                                        <van-field v-model="item.GSSEndDate" readonly label="结束灌酸时间"
                                            placeholder="请选择结束灌酸时间">
                                        </van-field>
                                        <van-button v-if='item.GSSEndDate' size="mini" disabled type="danger">
                                            结束灌酸
                                        </van-button>
                                        <van-button v-else size="mini" type="danger" @click="handlerAdd('结束灌酸',index)">
                                            结束灌酸
                                        </van-button>
                                    </div>
                                    <div v-show='api.pageParam.GSRow'>
                                        <van-field v-model="item.KJYJDate" readonly label="充电时间" placeholder="充电时间">
                                        </van-field>
                                    </div>
                                </div>
                            </van-col>
                        </van-row>
                    </div>
                </div>

                <div class="bottomBtn" v-show="api.deviceModel != 'TC27'">
                    <van-button size="small" type="info" @click="confirm" v-show="api.deviceModel != 'TC27'">
                        提交
                    </van-button>
                </div>
            </div>
            <audio id="audioPlayer" preload="auto">
                <source src="../image/aigei_com.mp3" type="audio/mpeg">
            </audio>
            <div class="indexBottom">
                汇智云创 技术支持
            </div>
            <van-action-sheet v-model="titleShow" :actions="titleActions" @select="onSelectTitle">
            </van-action-sheet>
            <van-dialog v-model="dialogShow" title="提示: 请选择作业员" show-cancel-button @confirm='dialogConfirm'
                @cancel='dialogCancel'>

                <div class="van-cell van-field">
                    <span style='padding:  0 5px;'>作业员</span>
                    <div class="Operator" @click="handlerTitle">
                        <span @click='closetitle($event,index)' class="van-tags van-tag--info"
                            v-for="(item, index) in dialogtitle">
                            {{ item }}
                            <i class="van-icon van-icon-clear"></i>
                        </span>
                    </div>
                </div>

            </van-dialog>

            <van-action-sheet v-model="SJNohow" style="height:80%;width: 100%;" @close='changeSJNohow'>
                <div class="custom-action-row  sheetdiv">
                    <div class='sheetdivchild' v-for='item,index in SJNoActions' :key='index'
                        @click='onSelectSJNo(item)' @dblclick="clickFun(item)">
                        <span style="font-size: 20px;font-weight: 600;"
                            :class="{ 'selected': formData.shangjiaList[currentIndex].SJNo.includes(item.name) && formData.shangjiaList[currentIndex].MF=='D'}"
                            v-if="formData.shangjiaList[currentIndex].MF == 'B'||formData.shangjiaList[currentIndex].MF == 'D'">
                            {{item.name}}
                        </span>
                        <span v-else>
                            <span v-if='formData.shangjiaList[currentIndex].MF == "A"'
                                class="sheetchild1">{{item.value1}}</span>
                            <span v-else class="sheetchild2">{{item.value1}}</span>
                            <span
                                :class="{ 'SJNoActionsMF': formData.shangjiaList[currentIndex].MF=='E'}">{{item.value2}}</span>
                        </span>
                    </div>
                    <div style="width: 100%;background-color: #fff;" v-show='pageCount!=1'>
                        <van-pagination v-model="pageIndex" :page-count="pageCount" mode="simple"
                            @change='changePagination' />
                    </div>
                </div>
            </van-action-sheet>

            <van-action-sheet v-model="SJQtyShow" :actions="SJQtyActions" @select="onSelectSJQty">
            </van-action-sheet>
            <van-action-sheet v-model="PlanAllShow" style="height:50%;width: 100%;">
                <div class="custom-action-row" class='sheetdivchild2'>
                    <div v-for='item,index in PlanDateAll' :key='index' style='padding:1%'
                        @click='changedate(item,index)'>
                        <span>{{item.ProductName}}</span>
                    </div>
                </div>
            </van-action-sheet>
            <van-dialog v-model="passwordshow" title="请输入口令" show-cancel-button @confirm="handlerDialog"
                @cancel="cancelDialog">
                <!--输入框-->
                <van-field v-model="message" rows="1" autosize label="口令：" type="password" placeholder="请输入口令" />
            </van-dialog>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {

        var scanTC27 = api.require('scanTC27');

        api.addEventListener({
            name: 'reshAddAcidDetail'
        }, function (ret) {
            let deepClone = APP.deepClone(ret.value.list)
            console.log('446ss', JSON.stringify(ret))
            if (!deepClone.CS) {
                deepClone.CS = JSON.parse(window.localStorage.getItem('userInfo')).className
            }
            console.log('446ssdeepClone', JSON.stringify(deepClone))
            deepClone.shangjiaList.forEach(item => {
                if (item.GSSEndDate == '@') {
                    item.GSSEndDate = ''
                }
            })
            if (deepClone.GSID == 0) {
                vm.allshow = false

            } else {
                vm.allshow = true

            }
            Object.assign(vm.formData, deepClone)
            var list = JSON.parse(JSON.stringify(vm.formData))
            if (list.AssemblingID) {
                let existingItem = vm.signalrDataList.find(item => list.AssemblingID == item.AssemblingID);
                let findIndex = vm.signalrDataList.findIndex(item => list.AssemblingID == item.AssemblingID);
                if (existingItem) {
                    vm.signalrDataList[findIndex] = list
                } else {
                    vm.signalrDataList.push(list);

                }
                window.localStorage.setItem('signalrData', JSON.stringify(vm.signalrDataList))
            }
            vm.$forceUpdate()
        })


        api.addEventListener({
            name: 'onLunXunConnectStatus'
        }, function (ret) {
            vm.connectStatus = ret.value.cs;
        })

        api.addEventListener({
            name: 'resume'
        }, function (ret, err) {
            console.log(vm.connectStatus)
            if (!vm.connectStatus) {

                var name = JSON.parse(window.localStorage.getItem('pageName'))
                if (name == "灌酸 上架") {
                    api.sendEvent({
                        name: 'resumesendEvent',
                        extra: {
                            pageData: vm.formData,
                            pageName: vm.name
                        }
                    })
                }

            }

        });



        vm = new Vue({
            el: '#app',
            data: {
                TitleName: '',
                confirmObj: {},
                dialogShow: false,
                dialogtitle: [],
                titleIndex: '',
                titleShow: false,
                titleActions: [],
                setTime: null,
                signalrDataList: JSON.parse(window.localStorage.getItem('signalrData')) || [],
                pageIndex: 1,
                pageCount: 0,
                pageSize: 56,
                message: '',
                passwordshow: false,
                name: api.pageParam.name,
                sendmsgshow: false,
                connectStatus: true,
                formData: {
                    WoOrderID: '',
                    KQty: '',
                    classID: APP.getUserInfo().classID == 'C' ? 1 : 2,
                    AssemblingIDs: [],
                    AssemblingID: '',
                    GSID: 0,
                    PlanID: '',
                    PlanIDDe: '',
                    PlanDate: '',
                    ProductName: '',
                    Batch: '',
                    BatchList: [],
                    Date: '',
                    AssembleQty: '',
                    PlanQty: '',
                    GSStartDate: '',
                    GSSEndDate: '',
                    GSQty: 0,
                    AcidEmpl: '',
                    SJQty: '',
                    SJNo: '',
                    startDisabled: false,
                    endDisabled: false,
                    FinishedQty: '',
                    planRes: [],

                    IFSY: '',
                    shangjiaList: [
                        {
                            GSDeID: 0,
                            SJQty: '',
                            SJNo: [],
                            GSStartDate: '',
                            GSSEndDate: '',
                            MF: 'B',
                            SJG: []
                        }
                    ],
                    searchShow: false
                },
                PlanDateAll: [],
                PlanDateAllIndex: 0,
                PlanAllShow: false,
                SJNohow: false,
                SJNoActions: [],
                currentIndex: '',
                allshow: false,
                SJQtyIndex: '',
                SJQtyShow: false,
                SJQtyActions: [
                    {
                        name: 504,
                        value: 504
                    },
                    {
                        name: 560,
                        value: 560
                    },
                    {
                        name: 280,
                        value: 280
                    },
                    {
                        name: 252,
                        value: 252
                    },
                    {
                        name: 140,
                        value: 140
                    },
                    {
                        name: 126,
                        value: 126
                    },

                ],
                isSync: 1,
                clickTimeout: null, // 用于存储setTimeout的ID  
                addformData: {}
            },
            created: function () {
                var that = this;
                that.TitleName = '新增'
                that.dialogtitle = JSON.parse(window.localStorage.getItem('Job3')) || []
                window.localStorage.setItem('pageName', JSON.stringify(that.name))

                that.formData.AcidEmpl = APP.getUserInfo().UserName
                scanTC27.registerReceiver(function (ret, err) {
                    console.log('扫描' + JSON.stringify(ret))

                    if (ret.barcode && ret.barcode.indexOf('PGD') != -1) {
                        // if (ret.barcode && ret.barcode.indexOf('JH') != -1) {
                        that.formData.PlanID = ret.barcode.split('|')[1]
                        console.log(that.formData.PlanID)

                        APP.ajax('getDailyPlan_Job', { PlanID: that.formData.PlanID }, function (res) {
                            console.log('扫描计划' + JSON.stringify(res.ds))
                            that.formData.planRes = res.ds
                            that.formData.PlanDate = res.ds[0].CreateTime.split('T')[0]
                            that.sendmsg(0)
                        })
                    }
                    else if (ret.barcode && ret.barcode.indexOf('ZP') != -1) {
                        if (that.formData.PlanID) {
                            that.formData.AssemblingID = ret.barcode.split('|')[1]
                            console.log('AssemblingID' + JSON.stringify(that.formData.AssemblingID))
                            console.log('AssemblingID' + JSON.stringify(that.formData.AssemblingIDs))
                            if (that.formData.AssemblingIDs.includes(that.formData.AssemblingID)) {
                                api.confirm({
                                    title: '提示',
                                    msg: '不要重复扫码!',
                                    buttons: ['确定', '取消']
                                }, function (ret, err) {
                                });
                            } else {
                                that.formData.AssemblingIDs.push(that.formData.AssemblingID)
                                APP.ajax('getAssemblingRecordsDetail', { AssemblingID: that.formData.AssemblingID }, function (res) {
                                    console.log('AssemblingIDres' + JSON.stringify(res))
                                    if (res.ds[0]) {
                                        APP.ajax('getXJXC', { AssemblingID: that.formData.AssemblingID, PID: res.ds[0].ProductID }, function (data) {
                                            console.log(JSON.stringify(data))
                                            that.message = ''
                                            if (data.ds[0]) {
                                                console.log(JSON.stringify(that.formData.AssemblingIDs));
                                                console.log(data.ds[0].AssemblingID);
                                                console.log(that.formData.AssemblingIDs.includes(data.ds[0].AssemblingID + ''));

                                                if (!that.formData.AssemblingIDs.includes(data.ds[0].AssemblingID + '')) {
                                                    console.log(data.ds[0]);
                                                    console.log(data.ds[0].Batch);
                                                    api.confirm({
                                                        title: '提示',
                                                        msg: `存在更早的装配码(${data.ds[0].Batch})，不能扫码`,
                                                        buttons: ['确定', '取消']
                                                    }, function (ret, err) {
                                                        if (ret.buttonIndex == 1) {
                                                            that.addformData = res
                                                            that.passwordshow = true
                                                        } else {
                                                            that.formData.AssemblingIDs.pop();
                                                        }
                                                    });
                                                }
                                                else {
                                                    that.AddFormData(res)
                                                }

                                            }
                                            else {
                                                that.AddFormData(res)
                                            }
                                        })
                                    } else {
                                        api.confirm({
                                            title: '提示',
                                            msg: '该装配码不存在!',
                                            buttons: ['确定', '取消']
                                        }, function (ret, err) {
                                        });
                                    }
                                })
                            }
                        }
                        else {
                            api.confirm({
                                title: '提示',
                                msg: '请先输入计划码！',
                                buttons: ['确定', '取消']
                            }, function (ret, err) {

                            });

                        }
                    }
                })
                setInterval(function () {
                    APP.addTime()
                    APP.getCDAlarmLList()
                    APP.getYCKBDataLiist()
                }, 60000)
                if (api.pageParam.GSRow && api.pageParam.GSRow.GSID != 0 && api.pageParam.msg != '首页') {
                    that.formData.GSID = api.pageParam.GSRow.GSID
                    that.allshow = true
                    try {
                        APP.ajax('getGSDetail_Job', { GSID: that.formData.GSID }, function (res) {
                            try {
                                that.TitleName = '详情'
                                console.log('res.ds1', JSON.stringify(res))
                                that.formData = res.ds[0]
                                that.formData.classID = APP.getUserInfo().classID == 'C' ? 1 : 2
                                that.formData.BatchList = res.ds[0].Batch ? res.ds[0].Batch.split(',') : [];
                                that.formData.AssemblingIDs = res.ds[0].AssemblingID.split(',')
                                that.formData.KQty = res.ds[0].KQty
                                that.formData.PlanQty = res.ds[0].Qty
                                that.formData.GSG = res.ds[0].GSG ? res.ds[0].GSG : APP.getUserInfo().UserName
                                that.formData.AcidEmpl = res.ds[0].GSG
                                that.formData.IFSY = res.ds[0].IFSY ? '样品' : ''
                                that.formData.PlanDate = res.ds[0].PlanDate ? res.ds[0].PlanDate.split('T')[0] : ''
                                that.formData.Date = res.ds[0].OperateDate.split('T')[0]
                                res.ds1.map(item => {
                                    if (item.SJNo == null) {
                                        item.SJNo = ''
                                    }
                                    return item.SJNo = item.SJNo.split(',')
                                })
                                res.ds1.map((item) => {
                                    item.GSStartDate = item.GSStartDate ? item.GSStartDate.replace('T', ' ') : ''
                                    item.GSSEndDate = item.GSSEndDate ? item.GSSEndDate.replace('T', ' ') : ''
                                })
                                console.log('res.ds2', JSON.stringify(res.ds1))
                                that.formData.shangjiaList = res.ds1
                            } catch (error) {
                                alert(error)
                            }

                        })

                    } catch (error) {
                        alert(error)

                    }

                }

                setInterval(function () {
                    api.sendEvent({
                        name: 'LunXunConnectStatus'
                    })
                }, 1000)
            },
            mounted() {
                APP.addTime()
                APP.setSafeTop()
                APP.keyBoardChange()
            },
            methods: {
                AddFormData(res) {
                    var that = this
                    console.log('产品接口  getAssemblingRecordsDetail' + JSON.stringify(res))
                    console.log('详情接口  getGSDetail_Job' + JSON.stringify(that.formData))

                    if (that.formData.ProductSunName && that.formData.ProductSunName != res.ds[0].ProductName) {
                        api.toast({
                            msg: '产品名称不一致！'
                        })
                        return false
                    }
                    console.log('496PlanIDDe' + JSON.stringify(that.formData.planRes))
                    if (that.TitleName != '详情') {
                        that.formData.planRes.map((item) => {
                            console.log('498PlanIDDe' + JSON.stringify(item))
                            if (item.ProductSunID == res.ds[0].ProductID && item.IFSY == res.ds[0].IFSY) {
                                that.formData.IFSY = item.IFSY ? '样品' : ''
                                that.formData.PlanIDDe = item.PlanIDDe
                                that.formData.FinishedQty = item.FinishedQty
                                that.formData.PlanQty = item.Qty
                                that.formData.GSQty = item.Qty
                                that.formData.WoOrderID = item.WoOrderID
                                that.formData.ProductName = item.ProductName
                            }
                        })
                    }
                    // that.formData.ProductName = res.ds[0].productname
                    that.formData.Batch = res.ds[0].Batch
                    that.formData.BatchList.push(res.ds[0].Batch)
                    that.formData.Date = res.ds[0].OperateDate.split('T')[0]
                    that.formData.AssembleQty = res.ds[0].Qty
                    that.formData.KQty = that.formData.KQty ? Number(that.formData.KQty) + Number(res.ds[0].KQty) : res.ds[0].KQty
                    that.sendmsg(0)

                },

                closetitle(event, index) {
                    var that = this
                    event.stopPropagation();
                    that.dialogtitle.splice(index, 1)
                    var ind = that.confirmObj.index
                    that.formData.shangjiaList[ind].SJG = that.dialogtitle
                    vm.$forceUpdate()

                },
                dialogConfirm() {
                    var that = this
                    var index = that.confirmObj.index
                    if (that.dialogtitle.length > 0) {
                        that.formData.shangjiaList[index].SJG = that.dialogtitle
                        console.log(JSON.stringify(that.formData.shangjiaList[index].SJG))
                        var obj
                        var mf = that.formData.shangjiaList[index].MF
                        var val = that.formData.shangjiaList[index].SJQty
                        window.localStorage.setItem('Job3', JSON.stringify(that.dialogtitle))

                        if (mf == 'A') {
                            var SJNo
                            var SJNo1 = that.formData.shangjiaList[index].SJNo.split(' ')[0]
                            var SJNo2 = that.formData.shangjiaList[index].SJNo.split(' ')[1]
                            var GSStartDate = that.formData.shangjiaList[index].GSSEndDate
                            if (SJNo2 == '15-28') {
                                // 空格不去掉
                                SJNo = SJNo1 + ' 1-14'
                                obj = {
                                    GSDeID: 0,
                                    SJQty: val,
                                    SJNo: SJNo,
                                    GSStartDate: GSStartDate,
                                    GSSEndDate: '',
                                    MF: mf,
                                    SJG: []

                                }
                                var addshow = true
                                that.formData.shangjiaList.forEach(item => {
                                    if (item.SJNo == SJNo) {
                                        api.toast({
                                            msg: SJNo + ' ' + '上架号已经在上架列表' + ' ' + '无需新增'
                                        })
                                        addshow = false
                                    }
                                })
                                if (addshow) {
                                    that.formData.shangjiaList.unshift(obj)
                                    vm.$forceUpdate()

                                }
                            }
                        }
                        else if (mf == 'C') {
                            var SJNo
                            var SJNo1 = that.formData.shangjiaList[index].SJNo.split(' ')[0]
                            var SJNo2 = that.formData.shangjiaList[index].SJNo.split(' ')[1]
                            var GSStartDate = that.formData.shangjiaList[index].GSSEndDate
                            if (SJNo2 == '3,4-27,28') {
                                // 空格不去掉
                                SJNo = SJNo1 + ' 1,2-25,26'
                                obj = {
                                    GSDeID: 0,
                                    SJQty: val,
                                    SJNo: SJNo,
                                    GSStartDate: GSStartDate,
                                    GSSEndDate: '',
                                    MF: mf,
                                    SJG: []

                                }
                                var addshow = true
                                that.formData.shangjiaList.forEach(item => {
                                    if (item.SJNo == SJNo) {
                                        api.toast({
                                            msg: SJNo + ' ' + '上架号已经在上架列表' + ' ' + '无需新增'
                                        })
                                        addshow = false
                                    }
                                })
                                if (addshow) {
                                    that.formData.shangjiaList.unshift(obj)
                                    vm.$forceUpdate()
                                }
                            }
                        }
                        that.sendmsg(0)
                    }
                    else {
                        api.toast({
                            msg: '请选择作业员'
                        })
                        that.dialogtitle = []
                        that.formData.shangjiaList[index].SJG = that.dialogtitle
                        that.formData.shangjiaList[index].GSSEndDate = ''
                    }

                },
                dialogCancel() {
                    var that = this
                    api.toast({
                        msg: '已取消选择作业员!'
                    })
                    var index = that.confirmObj.index
                    that.dialogtitle = []
                    that.formData.shangjiaList[index].SJG = that.dialogtitle
                    that.formData.shangjiaList[index].GSSEndDate = ''

                },
                handlerTitle() {
                    var that = this
                    that.titleShow = true
                    APP.ajax('getCDJobs', { Type: '上架' }, function (res) {
                        res.ds.map(item => item.name = item.Name)
                        console.log('getCDJobs' + JSON.stringify(res.ds))
                        that.titleActions = res.ds
                    })
                },
                onSelectTitle(val) {
                    var that = this
                    console.log(JSON.stringify(val))

                    if (that.dialogtitle.findIndex(item => { return item == val.name }) == -1) {
                        that.dialogtitle.push(val.name)
                        that.titleShow = false
                    } else {
                        api.toast({
                            msg: '已选择该人员，请勿重复选择！'
                        })
                    }
                    console.log(JSON.stringify(that.dialogtitle))
                },


                changeSJNohow() {
                    var that = this
                    if (that.formData.shangjiaList[that.currentIndex].MF != 'D') {
                        that.pageIndex = 1
                    }
                    else {
                        that.SJNohow = false
                    }
                    console.log('sssss', that.formData.shangjiaList[that.currentIndex].MF)
                },
                changedate(item, index) {
                    var that = this
                    that.formData = item
                    that.PlanAllShow = false
                    console.log('item', JSON.stringify(item))
                    vm.$forceUpdate()
                    that.isSync = 2;

                },
                changeblur(val, index) {
                    var that = this
                    console.log('changeblur', JSON.stringify(val))
                    console.log('index', JSON.stringify(index))
                    that.formData.shangjiaList[index].SJQty = val
                    vm.$forceUpdate()
                    that.sendmsg(0)

                },
                changeMF(item, index) {
                    var that = this
                    // that.formData.shangjiaList[index].SJNo = ''
                    console.log('index', index)
                    if (that.formData.shangjiaList[index].MF == 'A' || that.formData.shangjiaList[index].MF == 'C') {
                        var list = [
                            {
                                name: 252,
                                value: 252
                            },
                            {
                                name: 280,
                                value: 280
                            },
                            {
                                name: 140,
                                value: 140
                            },
                            {
                                name: 126,
                                value: 126
                            },
                        ]
                        that.SJQtyActions = list

                    } else if (that.formData.shangjiaList[index].MF == 'B') {
                        var list = [
                            {
                                name: 504,
                                value: 504
                            },
                            {
                                name: 560,
                                value: 560
                            },
                            {
                                name: 280,
                                value: 280
                            },
                            {
                                name: 252,
                                value: 252
                            },
                        ]
                        that.SJQtyActions = list
                    }

                    if (that.formData.shangjiaList[index].MF == 'D') {
                        that.formData.shangjiaList[index].SJNo = []
                        that.formData.shangjiaList[index].SJQty = ''
                    } else {
                        that.formData.shangjiaList[index].SJNo = ''
                        that.formData.shangjiaList[index].SJQty = ''
                    }
                    console.log('557', JSON.stringify(that.formData.shangjiaList))

                    that.sendmsg(0)
                    vm.$forceUpdate()

                },
                tbu() {
                    var that = this
                    that.sendmsg(1)
                },
                cancelDialog() {
                    var that = this

                    that.formData.AssemblingIDs.pop();

                },
                handlerDialog() {//确认or取消
                    var that = this
                    if (that.message == '') {
                        api.toast({
                            msg: '口令未输入'
                        })
                        that.message = ''

                        that.formData.AssemblingIDs.pop();

                    }
                    else {
                        var list = {
                            password: that.message
                        }
                        // 后续改回
                        // APP.ajax('getPassword', list, function (res) {
                        APP.ajax('getPassword1', list, function (res) {
                            if (res.ds[0].status == 200) {
                                api.toast({
                                    msg: '密码输入正确'
                                })
                                that.message = ''
                                that.AddFormData(that.addformData)
                            }
                            else {
                                api.toast({
                                    msg: '密码输入错误!'
                                })
                                that.message = ''
                                that.formData.AssemblingIDs.pop();
                            }

                        })
                    }
                },
                onClickLeft() {
                    var that = this
                    api.sendEvent({
                        name: 'refreshAddAcidDetailList'
                    })
                    if (api.pageParam.msg == '首页') {
                        setTimeout(() => {
                            api.closeToWin({
                                name: 'AddAcidList'
                            });
                        }, 100);
                    } else {
                        api.closeWin()

                    }
                },
                addNew() {
                    var that = this
                    var obj
                    if (that.formData.shangjiaList.length > 0) {
                        var val = that.formData.shangjiaList[that.formData.shangjiaList.length - 1].SJQty
                        var mf = that.formData.shangjiaList[that.formData.shangjiaList.length - 1].MF
                        obj = {
                            GSDeID: 0,
                            SJQty: val,
                            SJNo: '',
                            GSStartDate: '',
                            GSSEndDate: '',
                            MF: mf,
                            SJG: []
                        }
                    } else {
                        obj = {
                            GSDeID: 0,
                            SJQty: '',
                            SJNo: '',
                            GSStartDate: '',
                            GSSEndDate: '',
                            MF: 'B',
                            SJG: []
                        }
                    }
                    that.formData.shangjiaList.unshift(obj)
                    vm.$forceUpdate()
                    that.sendmsg(0)

                },
                deleteShangJiaList(index) {
                    var that = this
                    that.formData.shangjiaList.splice(index, 1)
                    vm.$forceUpdate()
                    that.sendmsg(0)
                },
                handlerSJQty(index) {
                    var that = this
                    that.SJQtyIndex = index
                    that.SJQtyShow = true
                    // vm.$forceUpdate()
                    // that.sendmsg(0)
                },

                onSelectSJQty(val) {
                    var that = this
                    console.log('val', JSON.stringify(val))
                    that.formData.shangjiaList[that.SJQtyIndex].SJQty = val.value
                    that.SJQtyShow = false
                    vm.$forceUpdate()
                    that.sendmsg(0)
                    console.log('执行')
                },
                changeAll() {
                    var that = this
                    that.PlanAllShow = true
                    console.log('signalrDataList' + JSON.stringify(that.signalrDataList))
                    console.log('that.signalrDataList' + JSON.stringify(that.signalrDataList))
                    if (that.signalrDataList) {
                        that.PlanDateAll = that.signalrDataList.filter(item => item.CS === JSON.parse(window.localStorage.getItem('userInfo')).className)
                        vm.$forceUpdate()
                    }

                },
                changePagination(val) {
                    var that = this
                    that.pageIndex = val
                    var list = {
                        CS: JSON.parse(window.localStorage.getItem('userInfo')).className,
                        MF: that.formData.shangjiaList[that.currentIndex].MF,
                        pageIndex: that.pageIndex,
                        pageSize: that.pageSize
                    }
                    console.log(JSON.stringify(list))
                    APP.ajax('getSJNo1', list, function (res) {
                        console.log('getSJNo1' + JSON.stringify(res))
                        that.SJNoActions = res.ds
                    })
                },

                handlerSJNo(SJNoIndex) {
                    var that = this
                    that.currentIndex = SJNoIndex
                    if (that.formData.shangjiaList[that.currentIndex].MF != 'D') {
                        that.pageIndex = 1
                    }
                    var list = {
                        CS: JSON.parse(window.localStorage.getItem('userInfo')).className,
                        MF: that.formData.shangjiaList[that.currentIndex].MF,
                        pageIndex: that.pageIndex,
                        pageSize: that.pageSize
                    }

                    console.log(JSON.stringify(list))
                    that.SJNohow = true

                    APP.ajax('getSJNo1', list, function (res) {
                        console.log('getSJNo1' + JSON.stringify(res))
                        that.SJNoActions = res.ds
                        if (res.ds1) {
                            that.pageCount = res.ds1[0].YM
                        }
                    })
                    if (that.formData.shangjiaList[that.currentIndex].MF == 'D' && that.formData.shangjiaList[that.currentIndex].SJNo == '') {
                        that.formData.shangjiaList[that.currentIndex].SJNo = []
                    }
                    that.sendmsg(0)
                },
                delayedClick() {
                    var that = this
                    that.clickTimeout = setTimeout(() => {
                    }, 300);
                },


                clickFun(item) {
                    var that = this
                    if (that.clickTimeout) {
                        clearTimeout(that.clickTimeout);
                        that.clickTimeout = null;
                    }
                    var index = that.formData.shangjiaList[that.currentIndex].SJNo.findIndex(obj => obj == item.name)
                    if (index != -1) {
                        that.formData.shangjiaList[that.currentIndex].SJNo.splice(index, 1)
                    }
                },
                onSelectSJNo(val) {
                    var that = this
                    var name
                    var confirmShow = false
                    if (that.clickTimeout) {
                        clearTimeout(that.clickTimeout);
                    }
                    that.clickTimeout = setTimeout(() => {
                        if (that.formData.shangjiaList[that.currentIndex].MF == 'B' || that.formData.shangjiaList[that.currentIndex].MF == 'D') {
                            name = val.name
                        }
                        else {
                            name = val.value1 + val.value2
                        }
                        if (that.formData.shangjiaList[that.currentIndex].MF == 'D') {
                            if (that.formData.shangjiaList[that.currentIndex].SJNo.findIndex(item => { return item == name }) == -1) {
                                var addshow = true
                                that.formData.shangjiaList.forEach(item => {
                                    if (item.SJNo.includes(name)) {
                                        api.confirm({
                                            title: '提示',
                                            msg: '已选择该上架号' + ' ' + name + ' ' + '请勿重复选择！',
                                            buttons: ['确定', '取消']
                                        }, function (ret, err) {
                                            if (ret.buttonIndex == 1) {
                                            }
                                        })
                                        addshow = false
                                    }
                                })
                                if (addshow) {
                                    that.formData.shangjiaList[that.currentIndex].SJNo.push(name)
                                    vm.$forceUpdate()
                                }
                            }
                            else {
                                api.toast({
                                    msg: '已选择该上架号，请勿重复选择！'
                                })
                            }

                        }
                        else if (that.formData.shangjiaList[that.currentIndex].MF == 'B') {
                            var msg = '是否为' + that.formData.shangjiaList[that.currentIndex].MF + '模式' + '  ' + name + '架' + '  ' + '充电'
                            confirmShow = true
                        }
                        else {
                            var msg = '是否为' + that.formData.shangjiaList[that.currentIndex].MF + '模式' + '  ' + name + '路' + '  ' + '充电'
                            confirmShow = true
                        }
                        if (confirmShow == true) {
                            api.confirm({
                                title: '提示',
                                msg: msg,
                                buttons: ['确定', '取消']
                            }, function (ret, err) {
                                if (ret.buttonIndex == 1) {
                                    var addshow = true
                                    that.formData.shangjiaList.forEach(item => {
                                        if (item.SJNo == val.name) {
                                            api.confirm({
                                                title: '提示',
                                                msg: '已选择该上架号' + ' ' + val.name + ' ' + '请勿重复选择！',
                                                buttons: ['确定', '取消']
                                            }, function (ret, err) {
                                                if (ret.buttonIndex == 1) {
                                                }
                                            })
                                            addshow = false
                                        }
                                    })
                                    if (addshow) {
                                        that.formData.shangjiaList[that.currentIndex].SJNo = name
                                        vm.$forceUpdate()
                                        that.SJNohow = false
                                        that.pageCount = 0

                                    }
                                    that.sendmsg(0)
                                } else {
                                    return
                                }
                            });

                        }
                        vm.$forceUpdate()
                        that.clickTimeout = null;
                    }, 300);


                },
                closeTag(event, index, idx) {
                    var that = this
                    event.stopPropagation();
                    that.formData.shangjiaList[index].SJNo.splice(idx, 1)
                    that.SJNohow = false

                    that.sendmsg(0)
                    vm.$forceUpdate()

                },

                sendmsg(flag, isSave = 1) {
                    let that = this

                    if (that.isSync == 2) {
                        that.isSync = 1;
                        return;
                    }
                    console.log('flag' + JSON.stringify(flag))

                    clearTimeout(that.setTime)
                    that.setTime = setTimeout(() => {
                        console.log('flag' + JSON.stringify(flag))
                        let obj = {
                            data: '',
                            flash: true,
                            isSave: isSave,
                            signalrDataList: that.signalrDataList
                        }
                        try {
                            console.log(flag);
                            if (flag) { //按钮
                                console.log('classID' + JSON.stringify(APP.getUserInfo().classID == 'C' ? 1 : 2))
                                // $.signalrApi.server.sendGSData(APP.getUserInfo().classID == 'C' ? 1 : 2, '', true);
                            } else {
                                var list = JSON.parse(JSON.stringify(that.formData))
                                if (!list.CS) {
                                    list.CS = JSON.parse(window.localStorage.getItem('userInfo')).className
                                }
                                console.log('446sslist', JSON.stringify(list))
                                if (list.AssemblingID) {
                                    let existingItem = that.signalrDataList.find(item => list.AssemblingID == item.AssemblingID);
                                    let findIndex = that.signalrDataList.findIndex(item => list.AssemblingID == item.AssemblingID);
                                    if (existingItem) {
                                        that.signalrDataList[findIndex] = list
                                    } else {
                                        that.signalrDataList.push(list);
                                    }
                                    window.localStorage.setItem('signalrData', JSON.stringify(that.signalrDataList))
                                }
                                vm.$forceUpdate()

                                obj['data'] = JSON.stringify(list);
                                obj['flash'] = false;
                                obj['signalrDataList'] = that.signalrDataList;
                                // $.signalrApi.server.sendGSData(APP.getUserInfo().classID == 'C' ? 1 : 2, JSON.stringify(list), false);
                            }
                            console.log(JSON.stringify(obj));
                            api.sendEvent({
                                name: 'sendMineMsg',
                                extra: {
                                    str: 'AddAcidDetail',
                                    data: obj
                                }
                            })
                        } catch {
                            that.sendmsg(0)
                        }
                    }, 500);


                },
                parseDate(dateStr) {
                    var that = this
                    const [year, month, day, hour, minute, second] = dateStr.split(/[- :]/);
                    return new Date(Date.UTC(year, month - 1, day, hour, minute, second));
                },
                calculateMinutesDiff(startTimeStr, endTimeStr) {
                    var that = this
                    startTimeStr.replace('T', ' ')
                    endTimeStr.replace('T', ' ')
                    const startTime = that.parseDate(startTimeStr);
                    const endTime = that.parseDate(endTimeStr);
                    // 计算时间差（毫秒）  
                    const diff = endTime - startTime;
                    // 将毫秒转换为分钟  
                    const minutesDiff = diff / (1000 * 60);
                    return minutesDiff;
                },


                handlerAdd(str, index) {
                    var that = this

                    if (str == '开始灌酸') {
                        that.formData.shangjiaList[index].GSStartDate = APP.getFormatDate(new Date())
                        that.sendmsg(0)
                    }
                    else if (str == '结束灌酸') {
                        if (!that.formData.shangjiaList[index].GSStartDate) {
                            api.toast({
                                msg: '请先开始灌酸！'
                            })
                            return false
                        }
                        var EndDateTime = APP.getFormatDate(new Date())
                        var onShow = false
                        const minutesDiff = that.calculateMinutesDiff(that.formData.shangjiaList[index].GSStartDate, EndDateTime);
                        console.log('minutesDiff', JSON.stringify(minutesDiff))
                        // 判断是否超过5分钟  
                        if (minutesDiff <= 5) {
                            alert('开始上架和结束上架未超过五分钟，不能提交')
                            that.formData.shangjiaList[index].GSSEndDate = ''
                            onShow = false
                            return false
                        }
                        else {
                            that.formData.shangjiaList[index].GSSEndDate = EndDateTime
                            onShow = true
                        }

                        if (onShow) {
                            that.confirmObj = {
                                str,
                                index
                            }
                            that.dialogShow = true

                        }

                        // that.sendmsg(0)
                    }
                    vm.$forceUpdate()
                },


                change() {
                    var that = this
                    that.formData = {
                        WoOrderID: '',
                        KQty: '',
                        classID: APP.getUserInfo().classID == 'C' ? 1 : 2,
                        AssemblingIDs: [],
                        AssemblingID: '',
                        GSID: 0,
                        PlanID: '',
                        PlanIDDe: '',
                        PlanDate: '',
                        ProductName: '',
                        Batch: '',
                        BatchList: [],
                        Date: '',
                        AssembleQty: '',
                        PlanQty: '',
                        GSStartDate: '',
                        GSSEndDate: '',
                        GSQty: 0,
                        AcidEmpl: '',
                        SJQty: '',
                        SJNo: '',
                        startDisabled: false,
                        endDisabled: false,
                        FinishedQty: '',
                        planRes: [],
                        IFSY: '',
                        shangjiaList: [
                            {
                                GSDeID: 0,
                                SJQty: '',
                                SJNo: [],
                                GSStartDate: '',
                                GSSEndDate: '',
                                MF: 'B',
                                SJG: []
                            }
                        ],
                        searchShow: false
                    }
                    vm.$forceUpdate()
                    setTimeout(() => {
                        if (api.pageParam.msg == '首页') {
                            setTimeout(() => {
                                api.closeToWin({
                                    name: 'AddAcidList'
                                });
                            }, 100);
                        } else {
                            api.sendEvent({
                                name: 'refreshAddAcidDetailList'
                            })
                            api.closeWin()

                        }
                    }, 1000);
                },
                // confirm() {
                //     const that = this;
                //     let isValid = true;
                //     let errorMessage = '';
                //     let shouldResetSJQty = false;
                //     let combinedSJNo = '';

                //     // 1. 校验上架列表数据
                //     const validateShangjiaList = () => {
                //         for (const [index, item] of that.formData.shangjiaList.entries()) {
                //             // 校验上架数量
                //             if (!item.SJQty || Number(item.SJQty) === 0) {
                //                 errorMessage = '上架数量不能为0或不能为空';
                //                 isValid = false;
                //                 break;
                //             }
                //             if (Number(item.SJQty) > 560) {
                //                 errorMessage = '上架数量不能大于560';
                //                 isValid = false;
                //                 shouldResetSJQty = true;
                //                 break;
                //             }
                //             if (['A', 'C'].includes(item.MF) && Number(item.SJQty) > 300) {
                //                 errorMessage = '超过半架最大数量';
                //                 isValid = false;
                //                 shouldResetSJQty = true;
                //                 break;
                //             }

                //             // 校验其他字段
                //             if (!item.SJNo) {
                //                 errorMessage = '上架号不能为空';
                //                 isValid = false;
                //                 break;
                //             }
                //             if (!item.GSStartDate) {
                //                 errorMessage = '开始灌酸时间不能为空';
                //                 isValid = false;
                //                 break;
                //             }
                //         }

                //         // 生成 combinedSJNo（优化后的拼接逻辑）
                //         combinedSJNo = that.formData.shangjiaList.map((item, i) => {
                //             const sjNo = Array.isArray(item.SJNo)
                //                 ? item.SJNo.join(',')
                //                 : item.SJNo;
                //             return i === 0 ? sjNo : `~${sjNo}`;
                //         }).join('');
                //     };

                //     // 2. 显示错误弹窗
                //     const showErrorDialog = () => {
                //         if (!isValid) {
                //             that.$confirm(
                //                 `<span style="color: red;">${errorMessage}</span>`,
                //                 '提示',
                //                 {
                //                     confirmButtonText: '确定',
                //                     cancelButtonText: '取消',
                //                     dangerouslyUseHTMLString: true,
                //                     type: 'warning',
                //                 }
                //             ).then(() => {
                //                 if (shouldResetSJQty) {
                //                     const invalidItem = that.formData.shangjiaList.find(item =>
                //                         !item.SJQty || Number(item.SJQty) > 560 ||
                //                         (['A', 'C'].includes(item.MF) && Number(item.SJQty) > 300)
                //                     );
                //                     if (invalidItem) invalidItem.SJQty = '';
                //                 }
                //             });
                //         }
                //     };

                //     // 3. 处理提交逻辑
                //     const handleSubmit = (isModify) => {
                //         const action = isModify ? '修改' : '提交';
                //         that.$confirm(`是否确认${action}！`, '提示', {
                //             confirmButtonText: '确定',
                //             cancelButtonText: '取消',
                //             type: 'warning',
                //         }).then(({ buttonIndex }) => {
                //             if (buttonIndex === 1) {
                //                 that.formData.shangjiaList.forEach(item => {
                //                     if (!item.GSSEndDate) item.GSSEndDate = '@';
                //                 });

                //                 const commonParams = {
                //                     WoOrderID: that.formData.WoOrderID,
                //                     PlanID: that.formData.PlanID,
                //                     GSID: that.formData.GSID,
                //                     AssemblingID: that.formData.AssemblingIDs.join(','),
                //                     GSQty: that.formData.GSQty,
                //                     GSG: that.formData.AcidEmpl,
                //                     PlanIDDe: that.formData.PlanIDDe,
                //                     ZPQty: that.formData.KQty,
                //                     IFSY: that.formData.IFSY === '样品',
                //                     Batch: that.formData.BatchList.join(','),
                //                 };

                //                 const apiName = isModify ? 'saveGS_Job' : 'saveGS_Job';
                //                 APP.ajax(apiName, commonParams, (res) => {
                //                     if (res.ds[0].status === 500) {
                //                         that.$toast(res.ds[0].msg);
                //                         return;
                //                     }

                //                     that.formData.GSID = res.ds1[0].GSID;
                //                     that.sendmsg(0);

                //                     const subObj = {
                //                         GSID: that.formData.GSID,
                //                         SJQty: that.formData.shangjiaList.map(item => item.SJQty).join(','),
                //                         SJNo: combinedSJNo,
                //                         GSDEID: that.formData.shangjiaList.map(item => item.GSDeID).join(','),
                //                         GSStartDate: that.formData.shangjiaList.map(item => item.GSStartDate).join(','),
                //                         GSSEndDate: that.formData.shangjiaList.map(item => item.GSSEndDate).join(','),
                //                         MF: that.formData.shangjiaList.map(item => item.MF).join(','),
                //                         PlanIDDe: that.formData.PlanIDDe,
                //                         SJG: that.formData.shangjiaList.map(item => item.SJG).join('~'),
                //                     };

                //                     APP.ajax('saveSJ_Job', subObj, (subRes) => {
                //                         if (subRes.ds[0].status === 200) {
                //                             that.$toast(subRes.ds[0].msg);
                //                             that.resetForm();
                //                             that.$forceUpdate();
                //                             that.change();
                //                             api.sendEvent({ name: 'refreshAddAcidDetailList' });
                //                         } else {
                //                             that.$alert(subRes.ds[0].msg, '保存失败');
                //                             that.$forceUpdate();
                //                         }
                //                     });
                //                 });
                //             } else {
                //                 that.$toast(`${action}已取消!`);
                //                 that.formData.shangjiaList.forEach(item => {
                //                     if (item.GSSEndDate === '@') item.GSSEndDate = '';
                //                 });
                //             }
                //         });
                //     };

                //     // 4. 重置表单（提取为方法）
                //     that.resetForm = () => {
                //         that.formData = {
                //             WoOrderID: '',
                //             KQty: '',
                //             classID: APP.getUserInfo().classID === 'C' ? 1 : 2,
                //             AssemblingIDs: [],
                //             AssemblingID: '',
                //             GSID: 0,
                //             PlanID: '',
                //             PlanIDDe: '',
                //             PlanDate: '',
                //             ProductName: '',
                //             Batch: '',
                //             BatchList: [],
                //             Date: '',
                //             AssembleQty: '',
                //             PlanQty: '',
                //             GSStartDate: '',
                //             GSSEndDate: '',
                //             GSQty: '',
                //             SJQty: '',
                //             SJNo: '',
                //             startDisabled: false,
                //             endDisabled: false,
                //             FinishedQty: '',
                //             planRes: [],
                //             AcidEmpl: that.formData.AcidEmpl,
                //             shangjiaList: [{ GSDeID: 0, SJQty: '', SJNo: [], GSStartDate: '', GSSEndDate: '', MF: 'B' }],
                //         };
                //     };

                //     // 执行逻辑
                //     validateShangjiaList();
                //     if (!isValid) {
                //         showErrorDialog();
                //         return; 
                //     }

                //     if (that.allshow && that.formData.GSID !== 0) {
                //         handleSubmit(true); // 修改模式
                //     } else if (that.formData.PlanIDDe) {
                //         handleSubmit(false); // 提交模式
                //     } else {
                //         that.$alert(`该计划中没有 ${that.formData.ProductName} 产品，不能提交`);
                //         that.formData.shangjiaList.forEach(item => { item.GSSEndDate = ''; });
                //     }
                // }

                confirm() {
                    var that = this

                    var show = true
                    var confirmtitle = ''
                    var confirmshow = false
                    var confirmSJQty = false
                    var a
                    var b = ''
                    var c = ''
                    that.formData.shangjiaList.forEach((item, index) => {
                        if (Number(item.SJQty) == 0 || item.SJQty == '') {
                            confirmtitle = '上架数量不能为0或不能为空'
                            confirmshow = true
                            show = false
                        }
                        if (item.SJNo == '') {
                            confirmtitle = '上架号不能为空'
                            confirmshow = true
                            show = false

                        }
                        if (item.GSStartDate == '') {

                            confirmtitle = '开始灌酸时间不能为空'
                            confirmshow = true
                            show = false

                        }
                        if (Number(item.SJQty) > 560) {
                            confirmtitle = '上架数量不能大于560'
                            confirmshow = true
                            confirmSJQty = true
                            show = false

                        }
                        if (item.MF == 'A' && Number(item.SJQty) > 300) {
                            confirmtitle = '超过半架最大数量'
                            confirmshow = true
                            confirmSJQty = true

                            show = false

                        }
                        if (item.MF == 'C' && Number(item.SJQty) > 300) {
                            confirmtitle = '超过半架最大数量'
                            confirmshow = true
                            confirmSJQty = true

                            show = false

                        }
                        if (confirmshow) {
                            this.$confirm(`<span style="color: red;">${confirmtitle}</span>`, '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                dangerouslyUseHTMLString: true,
                                type: 'warning',
                            }).then(() => {
                                // 确认操作的代码
                                if (confirmSJQty) {
                                    item.SJQty = ''
                                }
                            }).catch(() => {
                                // 取消操作的代码
                            });
                        }

                        if (item.MF == 'D') {
                            if (index == 0) {
                                c = c + item.SJNo.map(item => item = item).join(',')
                            } else {
                                c = c + '~' + item.SJNo.map(item => item = item).join(',')
                            }
                        }
                        else {
                            if (index == 0) {
                                c = c + item.SJNo
                            } else {
                                c = c + '~' + item.SJNo
                            }
                        }
                    })
                    console.log('c' + JSON.stringify(c))

                    if (show) {
                        that.formData.shangjiaList.forEach(item => {
                            if (item.GSSEndDate == '') {
                                item.GSSEndDate = '@'
                            }
                        })
                        if (that.allshow && that.formData.GSID != 0) {
                            api.confirm({
                                title: '提示',
                                msg: '是否确认修改！',
                                buttons: ['确定', '取消']
                            }, function (ret, err) {
                                if (ret.buttonIndex == 1) {
                                    var obj = {
                                        WoOrderID: that.formData.WoOrderID,
                                        PlanID: that.formData.PlanID,
                                        GSID: that.formData.GSID,
                                        AssemblingID: that.formData.AssemblingIDs.join(','),
                                        GSQty: that.formData.GSQty,
                                        GSG: that.formData.AcidEmpl,
                                        PlanIDDe: that.formData.PlanIDDe,
                                        ZPQty: that.formData.KQty,
                                        IFSY: that.formData.IFSY == '样品' ? true : false,
                                        Batch: that.formData.BatchList.join(',')
                                    }
                                    console.log('obj' + JSON.stringify(obj))
                                    APP.ajax('saveGS_Job', obj, function (res) {
                                        // APP.ajax('saveGS', obj, function (res) {
                                        console.log('res' + JSON.stringify(res))
                                        if (res.ds[0].status == 500) {
                                            api.toast({
                                                msg: res.ds[0].msg
                                            })
                                        }
                                        else {
                                            that.formData.GSID = res.ds1[0].GSID
                                            that.sendmsg(0)
                                            var subObj = {
                                                GSID: that.formData.GSID,
                                                SJQty: that.formData.shangjiaList.map(item => item.SJQty).join(','),
                                                SJNo: c,
                                                GSDEID: that.formData.shangjiaList.map(item => item.GSDeID).join(','),
                                                GSStartDate: that.formData.shangjiaList.map(item => item.GSStartDate).join(','),
                                                GSSEndDate: that.formData.shangjiaList.map(item => item.GSSEndDate).join(','),
                                                MF: that.formData.shangjiaList.map(item => item.MF).join(','),
                                                PlanIDDe: that.formData.PlanIDDe,
                                                SJG: that.formData.shangjiaList.map(item => item.SJG).join('~')
                                            }
                                            console.log('saveSJ_Job', JSON.stringify(subObj))
                                            APP.ajax('saveSJ_Job', subObj, function (subRes) {
                                                console.log('subRes', JSON.stringify(subRes))
                                                if (subRes.ds[0].status == 200) {
                                                    that.formData = {
                                                        WoOrderID: '',
                                                        KQty: '',
                                                        classID: APP.getUserInfo().classID == 'C' ? 1 : 2,
                                                        AssemblingIDs: [],
                                                        AssemblingID: '',
                                                        GSID: 0,
                                                        PlanID: '',
                                                        PlanIDDe: '',
                                                        PlanDate: '',
                                                        ProductName: '',
                                                        Batch: '',
                                                        BatchList: [],
                                                        Date: '',
                                                        AssembleQty: '',
                                                        PlanQty: '',
                                                        GSStartDate: '',
                                                        GSSEndDate: '',
                                                        GSQty: '',
                                                        SJQty: '',
                                                        SJNo: '',
                                                        startDisabled: false,
                                                        endDisabled: false,
                                                        FinishedQty: '',
                                                        planRes: [],
                                                        AcidEmpl: that.formData.AcidEmpl,
                                                        shangjiaList: [
                                                            {
                                                                GSDeID: 0,
                                                                SJQty: '',
                                                                SJNo: [],
                                                                GSStartDate: '',
                                                                GSSEndDate: '',
                                                                MF: 'B'
                                                            }
                                                        ]
                                                    }

                                                    console.log('1161that.formData', JSON.stringify(that.formData))
                                                    that.message = ''
                                                    api.sendEvent({
                                                        name: 'refreshAddAcidDetailList'
                                                    })
                                                    vm.$forceUpdate()
                                                    that.change()
                                                    api.toast({
                                                        msg: subRes.ds[0].msg
                                                    })
                                                    that.sendmsg(0, "0")
                                                }
                                                else {
                                                    api.alert({
                                                        title: '保存失败!',
                                                        msg: JSON.stringify(subRes.ds[0].msg),
                                                    }, function (alertRet, alerterr) {
                                                        if (alertRet) {
                                                        }
                                                    });
                                                    vm.$forceUpdate()

                                                    that.allshow = true
                                                    that.message = ''
                                                }
                                            })
                                        }
                                    })
                                }
                                else {
                                    api.toast({
                                        msg: '修改已取消!'
                                    })
                                    vm.$forceUpdate()
                                    that.formData.shangjiaList.forEach(item => {
                                        if (item.GSSEndDate == '@') {
                                            item.GSSEndDate = ''
                                        }
                                    })
                                    that.message = ''
                                }
                            });
                        }
                        else {
                            api.confirm({
                                title: '提示',
                                msg: '是否确认提交！',
                                buttons: ['确定', '取消']
                            }, function (ret, err) {
                                var index = ret.buttonIndex;
                                console.log('index', JSON.stringify(index))
                                if (ret.buttonIndex == 1) {

                                    if (that.formData.PlanIDDe) {
                                        var obj = {
                                            WoOrderID: that.formData.WoOrderID,
                                            PlanID: that.formData.PlanID,
                                            GSID: that.formData.GSID,
                                            AssemblingID: that.formData.AssemblingIDs.join(','),
                                            GSQty: that.formData.GSQty,
                                            GSG: that.formData.AcidEmpl,
                                            PlanIDDe: that.formData.PlanIDDe,
                                            ZPQty: that.formData.KQty,
                                            IFSY: that.formData.IFSY == '样品' ? true : false,
                                            Batch: that.formData.BatchList.join(',')
                                        }
                                        console.log('obj' + JSON.stringify(obj))
                                        // saveGS_Job
                                        // APP.ajax('saveGS', obj, function (res) {
                                        APP.ajax('saveGS_Job', obj, function (res) {
                                            console.log('res' + JSON.stringify(res))
                                            if (res.ds[0].status == 500) {
                                                api.toast({
                                                    msg: res.ds[0].msg
                                                })
                                            }
                                            else {
                                                that.formData.GSID = res.ds1[0].GSID
                                                that.sendmsg(0)
                                                var subObj = {
                                                    GSID: that.formData.GSID,
                                                    SJQty: that.formData.shangjiaList.map(item => item.SJQty).join(','),
                                                    SJNo: c,
                                                    GSDEID: that.formData.shangjiaList.map(item => item.GSDeID).join(','),
                                                    GSStartDate: that.formData.shangjiaList.map(item => item.GSStartDate).join(','),
                                                    GSSEndDate: that.formData.shangjiaList.map(item => item.GSSEndDate).join(','),
                                                    MF: that.formData.shangjiaList.map(item => item.MF).join(','),
                                                    PlanIDDe: that.formData.PlanIDDe,
                                                    SJG: that.formData.shangjiaList.map(item => item.SJG).join('~')

                                                }
                                                console.log('997c', JSON.stringify(c))
                                                APP.ajax('saveSJ_Job', subObj, function (subRes) {
                                                    console.log('subRes' + JSON.stringify(subRes))
                                                    if (subRes.ds[0].status == 200) {
                                                        api.toast({
                                                            msg: subRes.ds[0].msg
                                                        })
                                                        setTimeout(() => {
                                                            that.formData = {
                                                                WoOrderID: '',
                                                                KQty: '',
                                                                classID: APP.getUserInfo().classID == 'C' ? 1 : 2,
                                                                AssemblingIDs: [],
                                                                AssemblingID: '',
                                                                GSID: 0,
                                                                PlanID: '',
                                                                PlanIDDe: '',
                                                                PlanDate: '',
                                                                ProductName: '',
                                                                Batch: '',
                                                                BatchList: [],
                                                                Date: '',
                                                                AssembleQty: '',
                                                                PlanQty: '',
                                                                GSStartDate: '',
                                                                GSSEndDate: '',
                                                                GSQty: '',
                                                                SJQty: '',
                                                                SJNo: '',
                                                                startDisabled: false,
                                                                endDisabled: false,
                                                                FinishedQty: '',
                                                                planRes: [],
                                                                AcidEmpl: that.formData.AcidEmpl,
                                                                shangjiaList: [
                                                                    {
                                                                        GSDeID: 0,
                                                                        SJQty: '',
                                                                        SJNo: [],
                                                                        GSStartDate: '',
                                                                        GSSEndDate: '',
                                                                        MF: 'B',
                                                                        SJG: []
                                                                    }
                                                                ]
                                                            }
                                                            that.sendmsg(0, "0")
                                                            vm.$forceUpdate()

                                                            api.sendEvent({
                                                                name: 'refreshAddAcidDetailList'
                                                            })
                                                            that.change()

                                                        }, 1000);

                                                    }
                                                    else {
                                                        api.alert({
                                                            title: '保存错误!',
                                                            msg: res.ds[0].msg,
                                                        }, function (alertRet, alerterr) {
                                                            if (alertRet) {

                                                            }
                                                        });
                                                    }

                                                })

                                            }
                                        })

                                    }
                                    else {
                                        alert(`该计划中没有 ${that.formData.ProductName} 产品，不能提交`)
                                        that.formData.shangjiaList.forEach(item => {
                                            item.GSSEndDate = ''
                                        })
                                    }

                                }
                                else {
                                    api.toast({
                                        msg: '提交已取消!'
                                    })

                                    that.formData.shangjiaList.forEach(item => {

                                        if (item.GSSEndDate == '@') {
                                            item.GSSEndDate = ''
                                        }

                                    })

                                }
                            });

                        }

                    }
                }

            }
        })
    };
</script>

</html>